﻿#ifndef DYNAMICPLOT_H
#define DYNAMICPLOT_H

#include <QtCharts/QChartGlobal>
#include <QtCharts/QLineSeries>
#include <QtCharts/QtCharts>
#include <QtCharts/QChartView>
#include <QGridLayout>

QT_CHARTS_BEGIN_NAMESPACE
class QChartView;
class QChart;
QT_CHARTS_END_NAMESPACE

QT_CHARTS_USE_NAMESPACE

class DynamicPlot
{
public:
    DynamicPlot(QString title,qreal *buffer,int bufferLen,double stepLen,int minX=0,int maxX=30,int minY=-1,int maxY=1);

    void freshPlot();
    QChartView *getChartView();
    void destroy();

private:
    int minX,maxX,minY,maxY;
    QString title;
    qreal *buffer = nullptr;
    int bufferLen;
    double stepLen;

    QChart *chart = nullptr;
    QLineSeries *series = nullptr;
    QChartView *chartView = nullptr;

};

#endif // DYNAMICPLOT_H
